
import breed_import

class component:
	def __init__(self):
		self.lex = None
		self.ID = None
	
	def readNext(self):
		count = 0
		if ( len(self.lex) == 0 ): return None
		return self.lex.popleft()

	
	def p_import(self,token):
		breed_import.compile(self.lex)

	def p_at(self,token):
		{
			"DEFINE": lambda token : token,
			"FUNCTION": lambda token : token 
				
		}.get(token.type,self.p_default)(token)
	
	def p_default(self,token):
		#print "error token_id : " + token.value
		return None
	# Compile Component source
	def compile(self,lex):
		self.lex = lex
		
		token = self.readNext()
		self.ID = { "ID" : lambda token : token }.get(token.type,self.p_default)(token)
		print self.ID
		#processing statment	
		while(True):
			token = self.readNext()
			if token == None: break
			#syn begin
			{
				"AT" : lambda token : self.p_at(token),
				"IMPORT": lambda token : self.p_import(token) 
			}.get(token.type,self.p_default)(token)

import g_class
g_class.ADD("component",component)
